<?php
namespace app\course\validate\live;

use think\Validate;

/**
 * CC直播间验证
 */
class LiveBoke extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'section_id'    => 'require|integer',
        'userid'        => ['regex' => '/^[\w]{16}$/'],
        'roomid'        => ['require', 'regex' => '/^[\w]{32}$/'],
        'viewertoken'   => ['require', 'regex' => '/^[A-Za-z]{16}\:[A-Za-z]{16}$/', 'max' => 33],
    ];

    protected $field = [
        'section_id'     => '课时ID',

    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'create_room'       => ['section_id'],
        'room_entry_auth'   => ['userid', 'roomid', 'viewertoken'],
    ];

}
